<template>
   <view>
      <view class="m-list" v-for="(item, index) in courseList" :key="index">
         <uni-list class="m-item">
            <uni-list-item @click="toBook(item)">
               <view>
                 {{item.name}}
               </view>
               <view>
                 {{item.teacherName}}
               </view>
               <view>
                 {{item.startTime}} - {{item.endTime}}
               </view>
            </uni-list-item>
         </uni-list>
      </view>
   </view>
</template>

<script>
   import env from '@/env';
   
   export default {
      data() {
         return {
            type: 1,
            courseList: [] 
         }
      },
      onLoad(options) {
      	this.getCourseList();
      },
      methods: {
         getCourseList() {
            uni.request({
               url: env.BASE_URI + '/course/type/' + this.type,
               success: (res) => {
                  this.courseList = res.data;
               }
            });
         },
         toBook(course) {
            uni.navigateTo({
            	url: '/pages/book/book',
            });
         }
      }
   }
</script>

<style lang="scss" scoped>
	@import "./courses.scss";
</style>
